package com.tonann.app.mapper;


import com.tonann.app.domain.AppSensorRecord;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.session.ResultHandler;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 运行记录Mapper接口
 *
 * @author tonann
 * @date 2022-10-21
 */
public interface AppSensorRecordMapper extends BaseMapper<AppSensorRecord> {
    /**
     * 查询运行记录
     *
     * @param recordId 运行记录主键
     * @return 运行记录
     */
    public AppSensorRecord selectAppSensorRecordByRecordId(Long recordId);

    /**
     * 查询运行记录列表
     *
     * @param appSensorRecord 运行记录
     * @return 运行记录集合
     */
    public List<AppSensorRecord> selectAppSensorRecordList(AppSensorRecord appSensorRecord);

    public List<AppSensorRecord> selectAppSensorRecordPureList(AppSensorRecord appSensorRecord);
    /**
     * 新增运行记录
     *
     * @param appSensorRecord 运行记录
     * @return 结果
     */
    public int insertAppSensorRecord(AppSensorRecord appSensorRecord);

    @Override
    public int insertBatch(List<AppSensorRecord> list);

    /**
     * 修改运行记录
     *
     * @param appSensorRecord 运行记录
     * @return 结果
     */
    public int updateAppSensorRecord(AppSensorRecord appSensorRecord);

    /**
     * 删除运行记录
     *
     * @param recordId 运行记录主键
     * @return 结果
     */
    public int deleteAppSensorRecordByRecordId(Long recordId);

    /**
     * 批量删除运行记录
     *
     * @param recordIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAppSensorRecordByRecordIds(Long[] recordIds);

    AppSensorRecord selectAppSensorRecordBySensorId(Long sensorId);

    AppSensorRecord selectPreNoZeroAppSensorRecordByRecordId(@Param("recordId") Long recordId,@Param("sensorId") Long sensorId);
    @Select("SELECT * FROM app_sensor_record")
    @Options(fetchSize = 100000)
    Cursor<AppSensorRecord> streamAllRecord(@Param("fetchSize") int fetchSize);
    List<AppSensorRecord> selectList(List<Long> list);

    AppSensorRecord selectPreNoZeroAppSensorRecordByTime(@Param("createTime") LocalDateTime  createTime,@Param("sensorId") Long sensorId);

    void deleteAppSensorRecordBefore30Day();

    List<Long> selectSensorIdList();
}
